package com.example.javaproject.thread;

/**
 * Description: ThreadLocal测试
 * <br/>Author:  tianjinyong
 * <br/>Date:    2020/7/20 2:22 PM
 */
public class ThreadLocalTest {


    private static ThreadLocal<String> mThreadLoal;

    public static void main(String[] args) {
        testThreadLocal();
    }


    private static void testThreadLocal() {
        mThreadLoal = new ThreadLocal<>();

        new Thread(() -> {
            mThreadLoal.set("abcd");
            System.out.println(Thread.currentThread().getName() + mThreadLoal.get());
        }).start();


        new Thread(() -> {
            mThreadLoal.set("efg");
            System.out.println(Thread.currentThread().getName() + mThreadLoal.get());

        }).start();
    }

}
